package com.sw.c.controller;

import com.sw.c.utils.RocketMQProducerUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "测试RockerMQ消息消息队列")
@RestController
public class  RocketController {
    @Autowired
    private RocketMQProducerUtil mqProducerUtil;
    //消息主题
    private final String topic = "test001";


    @ApiOperation("同步消息")
    @GetMapping("/sendSync")
    public String sendSync(@RequestParam String message) {
        mqProducerUtil.sendSyncMessage(topic,message);
        return "同步消息发送成功";
    }
    @ApiOperation("异步消息")
    @GetMapping("/sendAsync")
    public String sendAsync(@RequestParam String message) {
        mqProducerUtil.sendAsyncMessage(topic,message);
        return "异步消息发送中";
    }
    @ApiOperation("单向消息")
    @GetMapping("/sendOneWay")
    public String sendOneWay(@RequestParam String message) {
        mqProducerUtil.sendOneWayMessage(topic,message);
        return "单向消息发送成功";
    }
}
